{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Find the Maximum Divisibility Score"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #array"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数组"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: maxDivScore"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #找出可整除性得分最大的整数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>给你两个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> 和 <code>divisors</code> 。</p>\n",
    "\n",
    "<p><code>divisors[i]</code> 的 <strong>可整除性得分</strong> 等于满足 <code>nums[j]</code> 能被 <code>divisors[i]</code> 整除的下标 <code>j</code> 的数量。</p>\n",
    "\n",
    "<p>返回 <strong>可整除性得分</strong> 最大的整数 <code>divisors[i]</code> 。如果有多个整数具有最大得分，则返回数值最小的一个。</p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>nums = [4,7,9,3,9], divisors = [5,2,3]\n",
    "<strong>输出：</strong>3\n",
    "<strong>解释：</strong>divisors 中每个元素的可整除性得分为：\n",
    "divisors[0] 的可整除性得分为 0 ，因为 nums 中没有任何数字能被 5 整除。\n",
    "divisors[1] 的可整除性得分为 1 ，因为 nums[0] 能被 2 整除。 \n",
    "divisors[2] 的可整除性得分为 3 ，因为 nums[2]、nums[3] 和 nums[4] 都能被 3 整除。 \n",
    "因此，返回 divisors[2] ，它的可整除性得分最大。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>nums = [20,14,21,10], divisors = [5,7,5]\n",
    "<strong>输出：</strong>5\n",
    "<strong>解释：</strong>divisors 中每个元素的可整除性得分为：\n",
    "divisors[0] 的可整除性得分为 2 ，因为 nums[0] 和 nums[3] 都能被 5 整除。\n",
    "divisors[1] 的可整除性得分为 2 ，因为 nums[1] 和 nums[2] 都能被 7 整除。\n",
    "divisors[2] 的可整除性得分为 2 ，因为 nums[0] 和 nums[3] 都能被5整除。 \n",
    "由于 divisors[0]、divisors[1] 和 divisors[2] 的可整除性得分都是最大的，因此，我们返回数值最小的一个，即 divisors[2] 。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>nums = [12], divisors = [10,16]\n",
    "<strong>输出：</strong>10\n",
    "<strong>解释：</strong>divisors 中每个元素的可整除性得分为：\n",
    "divisors[0] 的可整除性得分为 0 ，因为 nums 中没有任何数字能被 10 整除。\n",
    "divisors[1] 的可整除性得分为 0 ，因为 nums 中没有任何数字能被 16 整除。 \n",
    "由于 divisors[0] 和 divisors[1] 的可整除性得分都是最大的，因此，我们返回数值最小的一个，即 divisors[0] 。\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 &lt;= nums.length, divisors.length &lt;= 1000</code></li>\n",
    "\t<li><code>1 &lt;= nums[i], divisors[i] &lt;= 10<sup>9</sup></code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [find-the-maximum-divisibility-score](https://leetcode.cn/problems/find-the-maximum-divisibility-score/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [find-the-maximum-divisibility-score](https://leetcode.cn/problems/find-the-maximum-divisibility-score/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[4,7,9,3,9]\\n[5,2,3]', '[20,14,21,10]\\n[5,7,5]', '[12]\\n[10,16]']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        max_cnt, ans = -1, 0\n",
    "        for d in divisors:\n",
    "            cnt = sum(x % d == 0 for x in nums)\n",
    "            if cnt > max_cnt or cnt == max_cnt and d < ans:\n",
    "                max_cnt, ans = cnt, d\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        max_cnt, ans = -1, 0\n",
    "        for d in divisors:\n",
    "            cnt = sum(x % d == 0 for x in nums)\n",
    "            if cnt > max_cnt or cnt == max_cnt and d < ans:\n",
    "                max_cnt, ans = cnt, d\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        score, value = 0, int(10e9)\n",
    "        for each in divisors:\n",
    "            tmp_score = 0\n",
    "            for num in nums:\n",
    "                if num % each == 0:\n",
    "                    tmp_score += 1\n",
    "            if tmp_score > score:\n",
    "                score, value = tmp_score, each\n",
    "            if tmp_score == score and each < value:\n",
    "                value = each\n",
    "        return value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        max_cnt, ans = -1, 0\n",
    "        for d in divisors:\n",
    "            cnt = sum(x % d == 0 for x in nums)\n",
    "            if cnt > max_cnt or cnt == max_cnt and d < ans:\n",
    "                max_cnt, ans = cnt, d\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\r\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\r\n",
    "        divisors.sort()\r\n",
    "        \r\n",
    "        m = 0\r\n",
    "        ret = divisors[0]\r\n",
    "        for i in divisors:\r\n",
    "            cnt = 0\r\n",
    "            for j in nums:\r\n",
    "                if j % i == 0:\r\n",
    "                    cnt += 1\r\n",
    "            \r\n",
    "            if cnt > m:\r\n",
    "                m = cnt\r\n",
    "                ret = i\r\n",
    "\r\n",
    "        return ret\r\n",
    "\r\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        max_cnt = -1\n",
    "        ans = 0\n",
    "        for d in divisors:\n",
    "            cnt = sum(x % d == 0 for x in nums)\n",
    "            if cnt > max_cnt or cnt == max_cnt and d < ans:\n",
    "                max_cnt = cnt\n",
    "                ans = d\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        s = 0\n",
    "        i = divisors[0]\n",
    "        for x in divisors:\n",
    "            k = 0\n",
    "            for j in nums:\n",
    "                if j%x == 0:\n",
    "                    k += 1\n",
    "            if k > s:\n",
    "                i = x\n",
    "                s = k\n",
    "            elif k == s:\n",
    "                i = min(i,x)\n",
    "        return i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        # res=[]\n",
    "        m=len(divisors)\n",
    "        n=len(nums)\n",
    "        maxCount=0\n",
    "        max=0\n",
    "        res=divisors[0]\n",
    "        for index,div in enumerate(divisors):\n",
    "            ans=0\n",
    "            for num in nums:\n",
    "                if num%div==0:\n",
    "                    ans+=1\n",
    "            if ans>max:\n",
    "                max=ans\n",
    "                res=div\n",
    "            elif ans==max:\n",
    "                res=min(res,div)\n",
    "                \n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        maxd = -inf\n",
    "        ans = 0\n",
    "        for d in divisors:\n",
    "            if sum(n % d == 0 for n in nums) > maxd:\n",
    "                maxd = sum(n % d == 0 for n in nums)\n",
    "                ans = d\n",
    "            elif sum(n % d == 0 for n in nums) == maxd and d < ans:\n",
    "                ans = d\n",
    "\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], d: List[int]) -> int:\n",
    "        d.sort()\n",
    "        mx=0\n",
    "        ans=d[0]\n",
    "        for x in d :\n",
    "            cnt=0\n",
    "            for y in nums :\n",
    "                if y%x==0 :\n",
    "                    cnt+=1\n",
    "            if cnt>mx:\n",
    "                mx=cnt\n",
    "                ans=x\n",
    "        return ans\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        ans = inf\n",
    "        mx = 0\n",
    "        for j, x in enumerate(divisors):\n",
    "            cnt = 0\n",
    "            for i, y in enumerate(nums):\n",
    "                if y % x == 0:\n",
    "                    cnt += 1\n",
    "            if cnt > mx:\n",
    "                mx = cnt\n",
    "                ans = x\n",
    "            elif cnt == mx:\n",
    "                ans = min(ans, x)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        a,b=0,-1\n",
    "        divisors.sort()\n",
    "        for i in divisors:\n",
    "            cnt=0\n",
    "            for j in nums:\n",
    "                if j%i==0:\n",
    "                    cnt+=1\n",
    "            if cnt>b:\n",
    "                b=cnt\n",
    "                a=i\n",
    "        return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        # res=[]\n",
    "        m=len(divisors)\n",
    "        n=len(nums)\n",
    "        maxCount=0\n",
    "        max=0\n",
    "        res=divisors[0]\n",
    "        for index,div in enumerate(divisors):\n",
    "            ans=0\n",
    "            for num in nums:\n",
    "                if num%div==0:\n",
    "                    ans+=1\n",
    "            if ans>max:\n",
    "                max=ans\n",
    "                res=div\n",
    "            elif ans==max:\n",
    "                res=min(res,div)\n",
    "                \n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        t=0\n",
    "        s=divisors[0]\n",
    "        for divisor in divisors:\n",
    "            c=0\n",
    "            for num in nums:\n",
    "                if num % divisor==0:\n",
    "                    c+=1\n",
    "            if c>t: \n",
    "                t=c\n",
    "                s=divisor\n",
    "            elif c==t:\n",
    "                s=min(s,divisor)   \n",
    "        return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        ans=float(\"inf\")\n",
    "        cnt=0\n",
    "        for div in divisors:\n",
    "            c=0\n",
    "            for num in nums:\n",
    "                c+=(num%div==0)\n",
    "            if c>cnt:\n",
    "                cnt=c\n",
    "                ans=div\n",
    "            elif c==cnt:\n",
    "                ans=min(ans,div)\n",
    "        return ans\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        divisors = list(set(divisors))\n",
    "        _map = {x: 0 for x in divisors}\n",
    "        for a in divisors:\n",
    "            for b in nums:\n",
    "                if b % a == 0:\n",
    "                    _map[a] += 1\n",
    "        \n",
    "        soc = max(_map.values())\n",
    "        divisors.sort()\n",
    "        for x in divisors:\n",
    "            if _map[x] == soc:\n",
    "                return x\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        score = 0\n",
    "        ans = divisors[0]\n",
    "        for i in divisors:\n",
    "            temp = 0\n",
    "            for j in nums:\n",
    "                if j % i == 0:\n",
    "                    temp += 1\n",
    "            if temp > score:\n",
    "                score = temp\n",
    "                ans = i\n",
    "            elif temp == score:\n",
    "                ans = min(ans, i)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        max_cnt = -1\n",
    "        ans = 0\n",
    "        for d in divisors:\n",
    "            cnt = sum(x%d==0 for x in nums)\n",
    "            if cnt>max_cnt or cnt==max_cnt and d<ans:\n",
    "                max_cnt,ans = cnt,d\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        x = 0\n",
    "        y = float('inf')\n",
    "        for i in divisors:\n",
    "            z = sum(j%i==0 for j in nums)\n",
    "            if x < z:\n",
    "                x = z\n",
    "                y = i\n",
    "            elif x == z:\n",
    "                y = min(y, i)\n",
    "        return y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        score,ans = 0,float('inf')\n",
    "        for i in divisors:\n",
    "            temp = sum(1 for j in nums if j % i == 0)\n",
    "            if temp > score:\n",
    "                score = temp\n",
    "                ans = i\n",
    "            if temp == score:\n",
    "                ans = min(ans,i)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        res = 0\n",
    "        ans = divisors[0]\n",
    "        for d in divisors:\n",
    "            cnt = 0\n",
    "            for n in nums:\n",
    "                if n % d == 0:\n",
    "                    cnt += 1\n",
    "            if cnt > res:\n",
    "                res = cnt\n",
    "                ans = d\n",
    "            elif cnt == res:\n",
    "                ans = min(ans, d)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        ans,save = float('inf'),0\n",
    "        for d in divisors:\n",
    "            if sum(1 for n in nums if n % d == 0) > save:\n",
    "                save = sum(1 for n in nums if n % d == 0)\n",
    "                ans = d\n",
    "            elif sum(1 for n in nums if n % d == 0) == save and d < ans:\n",
    "                ans = d \n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        max_idx = 0\n",
    "        max_score = 0\n",
    "        for i,d in enumerate(divisors):\n",
    "            count = 0\n",
    "            for n in nums:\n",
    "                if n%d == 0:\n",
    "                    count += 1\n",
    "            if count>max_score:\n",
    "                max_idx = i\n",
    "                max_score = count\n",
    "            elif count==max_score and d<divisors[max_idx]:\n",
    "                max_idx = i\n",
    "                min_num = d\n",
    "        return divisors[max_idx]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        score = {div : 0 for div in divisors}\n",
    "        for num in nums:\n",
    "            for divisor in score.keys():\n",
    "                if num % divisor == 0:\n",
    "                    score[divisor] += 1\n",
    "        return sorted(score.items(), key = lambda x: (-x[1], x[0]))[0][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        m, n = len(nums), len(divisors)\n",
    "        ans, max_score = -1, -1\n",
    "        for i in range(n):\n",
    "            score = 0\n",
    "            for j in range(m):\n",
    "                if nums[j] % divisors[i] == 0:\n",
    "                    score += 1\n",
    "            if score >= max_score:\n",
    "                if score > max_score or divisors[i] < ans:\n",
    "                    max_score = score\n",
    "                    ans = divisors[i]\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        m, n = len(divisors), len(nums)\n",
    "        maxVal, maxCnt = 0, -1\n",
    "        visited = dict()\n",
    "        for i in range(m):\n",
    "            if divisors[i] in visited:\n",
    "                continue\n",
    "            \n",
    "            cnt = 0\n",
    "            for j in range(n):\n",
    "                if nums[j] % divisors[i] == 0:\n",
    "                    cnt += 1\n",
    "            visited[divisors[i]] = cnt\n",
    "            if cnt > maxCnt or (cnt == maxCnt and divisors[i] < maxVal):\n",
    "                maxVal, maxCnt = divisors[i], cnt\n",
    "        return maxVal"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        ans,save = float('inf'),0\n",
    "        for d in divisors:\n",
    "            if sum(1 for n in nums if n % d == 0) > save:\n",
    "                save = sum(1 for n in nums if n % d == 0)\n",
    "                ans = d\n",
    "            elif sum(1 for n in nums if n % d == 0) == save and d < ans:\n",
    "                ans = d \n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        nums.sort()\n",
    "        divisors.sort()\n",
    "        m=len(nums)\n",
    "        n=len(divisors)\n",
    "        df = 0\n",
    "        a=[]\n",
    "        for div in divisors:\n",
    "            jishu = 0\n",
    "            for i in range(m):\n",
    "                k=df -m \n",
    "                if nums[i] % div == 0:\n",
    "                    jishu +=1\n",
    "                if jishu -i < k:\n",
    "                    break\n",
    "            df = max(df,jishu)\n",
    "            a.append(jishu)\n",
    "        return divisors[a.index(df)]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        divisors.sort()\n",
    "        ans = divisors[0]\n",
    "        t = 0\n",
    "        for d in divisors:\n",
    "            s = 0\n",
    "            for n in nums:\n",
    "                if n % d == 0:\n",
    "                    s += 1\n",
    "            if s > t:\n",
    "                t = s\n",
    "                ans = d\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        divisors.sort()\n",
    "        mx = 0\n",
    "        ans = divisors[0]\n",
    "        for x in divisors:\n",
    "            cnt = sum(1 for i in range(len(nums)) if nums[i] % x == 0)\n",
    "            if cnt > mx:\n",
    "                mx = cnt\n",
    "                ans = x\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        divisors.sort()\n",
    "        mx = 0\n",
    "        ans = divisors[0]\n",
    "        for x in divisors:\n",
    "            cnt = 0\n",
    "            for i in range(len(nums)):\n",
    "                if nums[i] % x == 0:\n",
    "                    cnt += 1\n",
    "            if cnt > mx:\n",
    "                mx = cnt\n",
    "                ans = x\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# class Solution:\n",
    "#     def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "#         ans = -1\n",
    "#         max_cnt = -1\n",
    "#         for div in divisors:\n",
    "#             cnt = 0\n",
    "#             for num in nums:\n",
    "#                 cnt += (num % div == 0)\n",
    "#             if cnt > max_cnt:\n",
    "#                 max_cnt = cnt\n",
    "#                 ans = div\n",
    "#             elif cnt == max_cnt:\n",
    "#                 ans = min(ans,div)\n",
    "#         return ans\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        max_cnt, ans = -1, 0\n",
    "        for d in divisors:\n",
    "            cnt = sum(x % d == 0 for x in nums)\n",
    "            if cnt > max_cnt or cnt == max_cnt and d < ans:\n",
    "                max_cnt, ans = cnt, d\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        ans,save = float('inf'),0\n",
    "        for d in divisors:\n",
    "            t = sum(1 for n in nums if n % d == 0)\n",
    "            if t > save:\n",
    "                save = t\n",
    "                ans = d\n",
    "            elif t == save and d < ans:\n",
    "                ans = d \n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def get_score(self, num, divisors):\n",
    "        res = 0\n",
    "        for div in divisors:\n",
    "            if div % num == 0:\n",
    "                res += 1\n",
    "\n",
    "        return res\n",
    "\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        res, score = divisors[0], 0\n",
    "        for div in divisors:\n",
    "            _score = self.get_score(div, nums)\n",
    "            if _score > score or (_score == score and div < res):\n",
    "                score = _score\n",
    "                res = div\n",
    "\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        dic = {}\n",
    "        for d in divisors:\n",
    "            if d not in dic.keys():\n",
    "                count = 0\n",
    "                for n in nums:\n",
    "                    if n % d == 0:\n",
    "                        count += 1\n",
    "                dic[d] = count\n",
    "        # 对字典进行排序\n",
    "        v_max=0\n",
    "        k_v = max(divisors)\n",
    "        for k,v in dic.items():\n",
    "            if v > v_max:\n",
    "                v_max = v\n",
    "                k_v = k\n",
    "            elif v == v_max and k < k_v:\n",
    "                k_v = k \n",
    "        return k_v                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        big = res = -1\n",
    "        for d in divisors:\n",
    "            count = 0\n",
    "            for n in nums:\n",
    "                if n % d == 0:\n",
    "                    count += 1\n",
    "            if count > big:\n",
    "                big = count\n",
    "                res = d\n",
    "            elif count == big:\n",
    "                res = min(res, d)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        divisors.sort()\n",
    "        res=[]\n",
    "        for i in divisors:\n",
    "            temp=0\n",
    "            for j in nums:\n",
    "                if j%i==0:temp+=1\n",
    "            res.append(temp)\n",
    "        kk=max(res)\n",
    "        return divisors[res.index(kk)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        min_divisor = 0\n",
    "        max_score = -1\n",
    "        for divisor in divisors:\n",
    "            score = sum([1 if num % divisor == 0 else 0 for num in nums])\n",
    "            if score > max_score or (score == max_score and divisor < min_divisor):\n",
    "                min_divisor = divisor\n",
    "                max_score = score\n",
    "\n",
    "        return min_divisor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        ans,save = float('inf'),0\n",
    "        for d in divisors:\n",
    "            t = sum(1 for n in nums if n % d == 0)\n",
    "            if t > save:\n",
    "                save = t\n",
    "                ans = d\n",
    "            elif t == save and d < ans:\n",
    "                ans = d \n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        max_cnt, ans = -1, 0\n",
    "        for d in divisors:\n",
    "            cnt = sum(x % d == 0 for x in nums)\n",
    "            if cnt > max_cnt or cnt == max_cnt and d < ans:\n",
    "                max_cnt, ans = cnt, d\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        count = -1\n",
    "        divisors.sort()\n",
    "        for d in divisors:\n",
    "            cur = 0\n",
    "            for num in nums:\n",
    "                if num % d == 0:\n",
    "                    cur += 1\n",
    "\n",
    "            if cur > count:\n",
    "                count = cur \n",
    "                ans = d \n",
    "\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        divisors.sort()\n",
    "        ans = divisors[0]\n",
    "        t = 0\n",
    "        for d in divisors:\n",
    "            s = 0\n",
    "            for n in nums:\n",
    "                if n % d == 0:\n",
    "                    s += 1\n",
    "            if s > t:\n",
    "                t = s\n",
    "                ans = d\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        a, result = [], []\n",
    "        for i in range(len(divisors)):\n",
    "            n = 0\n",
    "            for j in nums:\n",
    "                if j % divisors[i] == 0:\n",
    "                    n += 1\n",
    "            a.append(n)\n",
    "        m = max(a)\n",
    "        for i in range(len(a)):\n",
    "            if a[i] == m:\n",
    "                result.append(divisors[i])\n",
    "\n",
    "        return min(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, a: List[int], b: List[int]) -> int:\n",
    "        h=defaultdict(int)\n",
    "        for i in b:\n",
    "            h[i]=0\n",
    "            for j in a:\n",
    "                if j%i==0:\n",
    "                    h[i]+=1\n",
    "        v=max(h.values())\n",
    "        for i in sorted(h.keys()):\n",
    "            if h[i]==v:\n",
    "                return i\n",
    "        return min(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        max_score = -1\n",
    "        max_index = -1 \n",
    "        for divisor in divisors:\n",
    "            score = sum(1 for num in nums if num % divisor == 0)\n",
    "            if score > max_score or (score == max_score and divisor < min_divisor):\n",
    "                min_divisor = divisor\n",
    "                max_score = score \n",
    "        return min_divisor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        _maxCnt, maxD = -1, -1\n",
    "        for d in divisors:\n",
    "            cnt = 0\n",
    "            for n in nums:\n",
    "                if n % d == 0:\n",
    "                    cnt += 1\n",
    "            if _maxCnt > cnt: continue\n",
    "            if _maxCnt < cnt:\n",
    "                maxD = d\n",
    "                _maxCnt = cnt\n",
    "            elif maxD > d:\n",
    "                maxD = d\n",
    "        return maxD\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        c = Counter(nums)\n",
    "        ds = sorted(set(divisors))\n",
    "        # print(ds)\n",
    "        n = 0\n",
    "        res = ds[0]\n",
    "        for d in ds:\n",
    "            dc = 0\n",
    "            for x, y in c.items():\n",
    "                if x % d == 0:\n",
    "                    dc += y\n",
    "            if dc > n:\n",
    "                n = dc\n",
    "                res = d\n",
    "            # print(d, dc, n)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        m = len(nums)\n",
    "        n = len(divisors)\n",
    "        a = [sum([1 for j in range(m) if nums[j]%divisors[i]==0]) for i in range(n)]\n",
    "        b = max(a)\n",
    "        c = [idx for idx in range(n) if a[idx]==b]\n",
    "        return min([divisors[idx] for idx in c])\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        nums.sort()\n",
    "        divisors.sort()\n",
    "        m=len(nums)\n",
    "        n=len(divisors)\n",
    "        df = 0\n",
    "        a=[]\n",
    "        for div in divisors:\n",
    "            jishu = 0\n",
    "            for num in nums:\n",
    "                if num % div == 0:\n",
    "                    jishu +=1\n",
    "            df = max(df,jishu)\n",
    "            a.append(jishu)\n",
    "        return divisors[a.index(df)]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        ans, max_div = min(divisors), 0\n",
    "        for i in divisors:\n",
    "            div = len([i for j in nums if j % i == 0])\n",
    "            if div > max_div:\n",
    "                max_div = div\n",
    "                ans = i\n",
    "            elif div == max_div:\n",
    "                ans = min(ans, i)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        divisors.sort()\n",
    "        m=len(nums)\n",
    "        n=len(divisors)\n",
    "        df = 0\n",
    "        a=[]\n",
    "        for div in divisors:\n",
    "            jishu = 0\n",
    "            for num in nums:\n",
    "                if num % div == 0:\n",
    "                    jishu +=1\n",
    "            df = max(df,jishu)\n",
    "            a.append(jishu)\n",
    "        return divisors[a.index(df)]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\r\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\r\n",
    "        res = 0\r\n",
    "        mxcnt = -1\r\n",
    "        for d in divisors:\r\n",
    "            cnt = 0\r\n",
    "            for x in nums:\r\n",
    "                if x % d == 0:\r\n",
    "                    cnt += 1\r\n",
    "            if cnt > mxcnt or cnt == mxcnt and d < res:\r\n",
    "                mxcnt = cnt\r\n",
    "                res = d\r\n",
    "        return res\r\n",
    "\r\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        max_cnt, ans = -1, 0\n",
    "        for d in divisors:\n",
    "            cnt = sum(x % d == 0 for x in nums)\n",
    "            if cnt > max_cnt or cnt == max_cnt and d < ans:\n",
    "                max_cnt, ans = cnt, d\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\r\n",
    "\r\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\r\n",
    "\r\n",
    "        di = {}\r\n",
    "        for n in nums:\r\n",
    "            if n not in di:\r\n",
    "                di[n] = 1\r\n",
    "            else:\r\n",
    "                di[n] += 1\r\n",
    "\r\n",
    "        divisors = sorted(list(set(divisors)))\r\n",
    "\r\n",
    "        res = -1\r\n",
    "        max_score = -1\r\n",
    "        for n in divisors:\r\n",
    "            score = 0\r\n",
    "            for k, v in di.items():\r\n",
    "                if k % n == 0: score += v\r\n",
    "            if score > max_score:\r\n",
    "                max_score = score\r\n",
    "                res = n\r\n",
    "\r\n",
    "        return res\r\n",
    "\r\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        ans = min(divisors)\n",
    "        mm = 0\n",
    "        nn, dd = Counter(nums), Counter(divisors)\n",
    "\n",
    "        for k2 in dd.keys():\n",
    "            v = 0\n",
    "            for k1 in nn.keys():\n",
    "                if k1 % k2 == 0:\n",
    "                    v += nn[k1]\n",
    "            if v > mm:\n",
    "                mm = v\n",
    "                ans = k2\n",
    "            elif v == mm:\n",
    "                ans = min(ans, k2)\n",
    "\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        hash=dict()\n",
    "        divisors.sort()\n",
    "        for ele in divisors:\n",
    "            hash[ele]=0\n",
    "            for ele1 in nums:\n",
    "                if ele1%ele==0:\n",
    "                    hash[ele]+=1\n",
    "        hash1=sorted(hash,key=hash.get,reverse=True)\n",
    "        return hash1[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        x=[]\n",
    "        for i in range(len(divisors)):\n",
    "            c=0\n",
    "            for j in range(len(nums)):\n",
    "                if nums[j]%divisors[i]==0:\n",
    "                    c+=1\n",
    "            x.append([divisors[i],c])\n",
    "        x=sorted(x,key=lambda i:(-i[1],i[0]))\n",
    "        return x[0][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        res = 0\n",
    "        ans = sorted(set(divisors))[0]\n",
    "        for d in divisors:\n",
    "            cnt = 0\n",
    "            for n in nums:\n",
    "                if n % d == 0:\n",
    "                    cnt += 1\n",
    "            if cnt > res:\n",
    "                res = cnt\n",
    "                ans = d\n",
    "            elif cnt == res:\n",
    "                ans = min(ans, d)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        score = {div : 0 for div in divisors}\n",
    "        for num in nums:\n",
    "            for divisor in score.keys():\n",
    "                if num % divisor == 0:\n",
    "                    score[divisor] += 1\n",
    "        return sorted(score.items(), key = lambda x: (-x[1], x[0]))[0][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        dct = defaultdict(list)\n",
    "        for d in divisors:\n",
    "            dct[len([1 for n in nums if n % d == 0])].append(d)\n",
    "        return min(dct[max(dct)])        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n",
    "        max_dict = {}\n",
    "        for i in divisors:\n",
    "            count = 0\n",
    "            for num in nums:\n",
    "                if num % i == 0:\n",
    "                    count += 1\n",
    "            max_dict[i] = count\n",
    "        d_list = list(max_dict.values())\n",
    "        max_value = int(max(d_list))\n",
    "        result = []\n",
    "        for key in max_dict.keys():\n",
    "            if max_dict.get(key) == max_value:\n",
    "                result.append(key)\n",
    "        return int(min(result))\n",
    "        "
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
